<template>
  <div>
    <div style="text-align:left">
      患者信息：
      <el-tag>姓名：{{patient.realName}}</el-tag>
      <el-tag>病历号：{{patient.caseNumber}}</el-tag>
      <el-tag>年龄：{{patient.age}}</el-tag>
      <el-tag>性别：{{patient.gender}}</el-tag>
    </div>
    <el-divider></el-divider>
    <div style="font-size:20px;text-align:left">
      <i class="el-icon-document-checked">检查结果：</i>
    </div>
    <el-divider></el-divider>
    <el-table :data="check_patient_table" style="width:80%" :row-key="row => {row.id}"
      highlight-current-row @current-change="checkSelectChange">
      <el-table-column type="index" width="50"></el-table-column>
      <el-table-column prop="techCode" label="检查编码" width="180"></el-table-column>
      <el-table-column prop="techName" label="检查名称" ></el-table-column>
      <el-table-column prop="techFormat" label="规格" width="180"></el-table-column>
      <el-table-column prop="techPrice" label="单价" width="120"></el-table-column>
      <el-table-column prop="checkState" label="状态" width="120"></el-table-column>
      <el-table-column prop="techType" label="费用分类" width="120"></el-table-column>
    </el-table>
    <el-divider></el-divider>

    <el-descriptions title="检查结果详情：" :column="1" border style="width:80%">
      <el-descriptions-item label="开立时间："   :contentStyle="{'background-color':'#F4F4F5'}":labelStyle="{'width':'120px'}">
        <el-tag type="info">{{dateFormate(check_info.creationTime)}}</el-tag>

      </el-descriptions-item>
      <el-descriptions-item label="检查医生：" :contentStyle="{'background-color':'#F4F4F5'}" :labelStyle="{'width':'120px'}">
        <el-tag type="info">{{check_info.realname}}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="录入医生：" :contentStyle="{'background-color':'#F4F4F5'}" :labelStyle="{'width':'120px'}">
        <el-tag type="info">{{check_info.inputRealName}}</el-tag>
      </el-descriptions-item>

      <el-descriptions-item label="检查部位：" :contentStyle="{'background-color':'#F4F4F5'}" :labelStyle="{'width':'120px'}">
        <el-tag type="info">{{check_info.checkPosition}}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="目的要求：" :contentStyle="{'background-color':'#F4F4F5'}" :labelStyle="{'width':'120px'}">
        <el-tag type="info">{{check_info.checkInfo}}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="医嘱备注：" :contentStyle="{'background-color':'#F4F4F5'}" :labelStyle="{'width':'120px'}">
        <el-tag type="info">{{check_info.checkRemark}}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="检查结果：" :contentStyle="{'background-color':'#F4F4F5'}" :labelStyle="{'width':'120px'}">
        <el-tag type="info">{{check_info.checkResult}}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="检查时间：" :contentStyle="{'background-color':'#F4F4F5'}" :labelStyle="{'width':'120px'}">
        <el-tag type="info">{{dateFormate(check_info.checkTime)}}</el-tag>
      </el-descriptions-item>
    </el-descriptions>
  </div>
</template>
<script>

import {isNullMessage} from "../../../util/util"
import {getSessionStorage} from "@/util/common";
import {ElMessage} from "element-plus";
import dayjs from "dayjs";

export default {
  data(){
    return{
      patient:{}, //患者信息
      check_patient_table:[],
      check_info:{},
    }    
  },
  methods:{

    //安装dayjs

    //npm install dayjs --save
    //https://dayjs.fenxianglu.cn/category/display.html#%E6%A0%BC%E5%BC%8F%E5%8C%96
    //日期格式函数
    dateFormate:function (date){

    //alt+enter 导入
      return dayjs(date).format("YYYY-MM-DD HH:mm:ss");
    },
    //查看医疗项目对应的项目信息
    checkSelectChange:function (row){
   // console.log(row)
      let medicalTechnologyId=row.id
      let registerId=this.patient.id
      let url=`http://localhost:8092/checkrequest/selectbyregisgerandmedicaltonologid/${registerId}/${medicalTechnologyId}`
      this.$axios.get(url).then(resp=>{
        this.check_info=resp.data.result
      }).catch(error=>{
        console.log(error)
      })
    },
    //得到当前患者的检查的项目
    getPatientMedicaltechnology:function ()
    {
      let url='http://localhost:8092/medicaltechnology/selectbyregiserid'
      let value={
        registerId:this.patient.id,
        checkState:'已出结果'
      }
      this.$axios.post(url,value).then(resp=>{
        this.check_patient_table=resp.data.result

      })
    },
  },
  mounted() {
    if(getSessionStorage("patient")==null)
    {
      ElMessage({
        type:"warning",
        message:'请选择患者！'
      })
      return
    }
    this.patient=getSessionStorage("patient")

    this.getPatientMedicaltechnology()
  }
}
</script>